package com.gg.user.gguser.controller;

import com.gg.user.gguser.service.GgBusinessOpportunityService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * 商机
 */

@RestController
@RequestMapping("/business")
public class GgBusinessOpportunityController {

    @Autowired
    private GgBusinessOpportunityService ggBusinessOpportunityService;


    /**
     * 增加 从信息地方新增过来的
     */
    @PostMapping("/addbusiness")
    public Object addBusiness(HttpServletResponse response, HttpServletRequest request, Integer id) throws Exception {
        return ggBusinessOpportunityService.addBusiness(response, request, id);
    }

    /**
     * 移除 商机移入信息
     */
    @PostMapping("/removebusiness")
    public Object removebusiness(HttpServletResponse response, HttpServletRequest request, Integer id) throws Exception {
        return ggBusinessOpportunityService.removebusiness(response, request, id);
    }


    /**
     * 修改
     */
    @PostMapping("/updatebusiness")
    public Object updateBusiness() {
        return ggBusinessOpportunityService.updateBusiness();
    }

    /**
     * 查询
     */
    @PostMapping("/getbusiness")
    public Object getBusiness(HttpServletResponse response, HttpServletRequest request, Integer page, Integer pageNumber, @RequestParam(name = "name", required = false) String name, @RequestParam(name = "type", required = false) Integer type, @RequestParam(name = "state", required = false) Integer state, @RequestParam(name = "remarks", required = false) String remarks) throws Exception {
        return ggBusinessOpportunityService.getBusiness(response, request, page, pageNumber, name, type, state, remarks);
    }

    /**
     * 删除商机
     */
    @PostMapping("/delectbusiness")
    public Object delectBusiness(HttpServletResponse response, HttpServletRequest request,Integer id) throws Exception{
        return ggBusinessOpportunityService.delectBusiness(response,request,id);
    }

    /**
     * 增加商机
     * @param response
     * @param request
     * @param ggBoNextTime  下次联系时间
     * @param name  信息名字
     * @param sex
     * @param position  职位
     * @param phone     手机号
     * @param mailbox   邮箱
     * @param qq        QQ
     * @param weChat    微信
     * @param provid    信息省份
     * @param cityid    信息省份
     * @param areaid    县/区
     * @param address   信息详细地址
     * @param level     级别
     * @param state     状态
     * @param remarks   备注说明
     * @param username      联系人
     * @param fax           传真
     * @param contact       联系人
     * @param zipcode       邮编
     * @param website       网站
     * @param source        信息来源
     * @return
     * @throws Exception
     */
    @PostMapping("/addBusinessAll")
    public Object addBusinessAll(HttpServletResponse response, HttpServletRequest request, String name,String ggBoNextTime, String sex, @RequestParam(name = "position", required = false) String position, String phone, @RequestParam(name = "mailbox", required = false) String mailbox, @RequestParam(name = "qq", required = false) String qq, @RequestParam(name = "weChat", required = false) String weChat, @RequestParam(name = "provid", required = false) String provid, @RequestParam(name = "cityid", required = false) String cityid, @RequestParam(name = "areaid", required = false) String areaid, @RequestParam(name = "address", required = false) String address, @RequestParam(name = "level", required = false) Integer level, @RequestParam(name = "state", required = false) Integer state, @RequestParam(name = "remarks", required = false) String remarks, @RequestParam(name = "username", required = false) String username, @RequestParam(name = "fax", required = false) String fax, @RequestParam(name = "contact", required = false) String contact, @RequestParam(name = "zipcode", required = false) String zipcode, @RequestParam(name = "website", required = false) String website, @RequestParam(name = "source", required = false) String source) throws Exception {
        return ggBusinessOpportunityService.addBusinessAll(response, request, name,ggBoNextTime, sex, position, phone, mailbox, qq, weChat, provid, cityid, areaid, address, level, state, remarks, username, fax, contact, zipcode, website, source);
    }

    /**
     * 查看商机详情
     */
    @PostMapping("/getBusinessSelectItems")
    public Object getBusinessSelectItems(HttpServletResponse response, HttpServletRequest request, String token) throws IOException {
        return ggBusinessOpportunityService.getBusinessSelectItems(response, request, token);
    }

    /**
     * 修改商机
     */
    @PostMapping("/updateBusiness")
    public Object updateBusiness(HttpServletResponse response, HttpServletRequest request, String ggItemsToken, @RequestParam(name = "ggBoName", required = false) String ggBoName, @RequestParam(name = "ggBoProvince", required = false)String ggBoProvince,@RequestParam(name = "ggBoCity", required = false) String ggBoCity,@RequestParam(name = "ggBoAreaid", required = false)String ggBoAreaid, @RequestParam(name = "ggBoDetailed", required = false)String ggBoDetailed, @RequestParam(name = "ggBoHandle", required = false)String ggBoHandle, @RequestParam(name = "ggBoContact", required = false)String ggBoContact, @RequestParam(name = "ggBoState", required = false)Integer ggBoState, @RequestParam(name = "ggBoLevel", required = false)Integer ggBoLevel, @RequestParam(name = "ggBoGender", required = false)String ggBoGender, @RequestParam(name = "ggBoPosition", required = false)String ggBoPosition, String ggBoTelephone, @RequestParam(name = "ggBoFax", required = false)String ggBoFax, @RequestParam(name = "ggBoMailbox", required = false)String ggBoMailbox, @RequestParam(name = "ggBoQq", required = false)String ggBoQq, @RequestParam(name = "ggBoWechat", required = false)String ggBoWechat,@RequestParam(name = "ggBoZipcode", required = false) String ggBoZipcode,@RequestParam(name = "ggBoWebsite", required = false) String ggBoWebsite,@RequestParam(name = "ggBoSource", required = false) String ggBoSource) throws Exception {
        return ggBusinessOpportunityService.updateBusiness(response, request, ggItemsToken, ggBoName, ggBoProvince, ggBoCity, ggBoAreaid, ggBoDetailed, ggBoHandle, ggBoContact, ggBoState, ggBoLevel, ggBoGender, ggBoPosition, ggBoTelephone, ggBoFax, ggBoMailbox, ggBoQq, ggBoWechat, ggBoZipcode, ggBoWebsite, ggBoSource);
    }

    /**
     * 商机批量  移除 商机移入信息
     */
    @PostMapping("/removebusinessAll")
    public Object removebusinessAll(HttpServletResponse response, HttpServletRequest request,String listid) {
        return ggBusinessOpportunityService.removebusinessAll(response, request, listid);
    }

    /**
     * 商机批量  删除
     */
    @PostMapping("/delectbusinessAll")
    public Object delectbusinessAll(HttpServletResponse response, HttpServletRequest request,String listid) throws Exception{
        return ggBusinessOpportunityService.delectbusinessAll(response, request, listid);
    }
}